<script setup lang="ts">
import { onMounted } from "vue";
import { roleApi } from "@/api";
import { useUserStore } from "@/stores/user";

defineOptions({
    name: "Menu2",
});

function testRoleCreateApi(payload?: any) {
    roleApi.create(payload);
}

onMounted(() => {
    console.info("Menu2 component mounted");
});
</script>

<template>
    <el-card>
        <div>
            <h3 class="mb-3">
                功能测试 - 接口测试
            </h3>
            <p class="mb-3">
                需要传参的类型: {code: string, name: string}, 当前角色: {{ useUserStore().roles }}
            </p>
            <div>
                <el-button @click="testRoleCreateApi({ code: null, name: null })">
                    缺少必填字段 {code:null,name:null}
                </el-button>
                <el-button @click="testRoleCreateApi({ code: 1, name: '1' })">
                    字段类型错误 {code:1,name:'1'}
                </el-button>
                <el-button @click="testRoleCreateApi({ code: 'super_admin', name: '超级管理员' })">
                    没有权限 (需要super_admin, 成功调用报数据已存在)
                </el-button>
                <el-button @click="testRoleCreateApi({ code: 'super_admin', name: '超级管理员' })">
                    数据已存在 {code:'super_admin',name:'超级管理员'}
                </el-button>
            </div>
        </div>
    </el-card>
</template>
